import 'dart:convert' show json;

// import 'dart:ffi';
typedef CommonJsonBuild<T> = T Function(dynamic);

/// 基础类==================================
///列表
class CommonJsonListRes<T> {
  String message;
  int code;
  List<T> result;

  bool get isSuccess => code == 200;

  CommonJsonListRes.fromParams({this.code, this.message, this.result});

  CommonJsonListRes.fromJson(jsonRes, CommonJsonBuild<T> build) {
    code = jsonRes['code'];
    message = jsonRes['msg'];
    if (build != null && jsonRes['data'] != null) {
      result =
          (jsonRes['data'] as List<dynamic>).map((e) => build(e)).toList();
    }
  }
}



class GuanJingJson {

  int code;
  double mpa;
  String data;
  String msg;
  List<GuanJinParm> options;

  GuanJingJson.fromParams({this.code, this.mpa, this.data, this.msg, this.options});

  factory GuanJingJson(Object jsonStr) => jsonStr is String ? GuanJingJson.fromJson(json.decode(jsonStr)) : GuanJingJson.fromJson(jsonStr);

  static GuanJingJson parse(jsonStr) => ['null', '', null].contains(jsonStr) ? null : GuanJingJson(jsonStr);

  GuanJingJson.fromJson(jsonRes) {
    code = jsonRes['code'];
    mpa = jsonRes['mpa'];
    data = jsonRes['data'];
    msg = jsonRes['msg'];
    options = jsonRes['options'] == null ? null : [];

    for (var optionsItem in options == null ? [] : jsonRes['options']){
      options.add(optionsItem == null ? null : GuanJinParm.fromJson(optionsItem));
    }
  }

  @override
  String toString() {
    return '{"code": $code, "mpa": $mpa, "data": ${data != null?'${json.encode(data)}':'null'}, "msg": ${msg != null?'${json.encode(msg)}':'null'}, "options": $options}';
  }

  String toJson() => this.toString();
}

class GuanJinParm {

  String item;

  GuanJinParm.fromParams({this.item});

  GuanJinParm.fromJson(jsonRes) {
    item = jsonRes['item'];
  }

  @override
  String toString() {
    return '{"item": ${item != null?'${json.encode(item)}':'null'}}';
  }

  String toJson() => this.toString();
}



class PengZhangJson {

  int code;
  double mpa;
  String data;
  String msg;

  PengZhangJson.fromParams({this.code, this.mpa, this.data, this.msg});

  factory PengZhangJson(Object jsonStr) => jsonStr is String ? PengZhangJson.fromJson(json.decode(jsonStr)) : PengZhangJson.fromJson(jsonStr);

  static PengZhangJson parse(jsonStr) => ['null', '', null].contains(jsonStr) ? null : PengZhangJson(jsonStr);

  PengZhangJson.fromJson(jsonRes) {
    code = jsonRes['code'];
    mpa = jsonRes['mpa'];
    data = jsonRes['data'];
    msg = jsonRes['msg'];
  }

  @override
  String toString() {
    return '{"code": $code, "mpa": $mpa, "data": ${data != null?'${json.encode(data)}':'null'}, "msg": ${msg != null?'${json.encode(msg)}':'null'}}';
  }

  String toJson() => this.toString();
}

class ZuLiFJson {

  int code;
  double mpa;
  String msg;
  List<ZuliItem> data;

  ZuLiFJson.fromParams({this.code, this.mpa, this.msg, this.data});

  factory ZuLiFJson(Object jsonStr) => jsonStr is String ? ZuLiFJson.fromJson(json.decode(jsonStr)) : ZuLiFJson.fromJson(jsonStr);

  static ZuLiFJson parse(jsonStr) => ['null', '', null].contains(jsonStr) ? null : ZuLiFJson(jsonStr);

  ZuLiFJson.fromJson(jsonRes) {
    code = jsonRes['code'];
    mpa = jsonRes['mpa'];
    msg = jsonRes['msg'];
    data = jsonRes['data'] == null ? null : [];

    for (var dataItem in data == null ? [] : jsonRes['data']){
      data.add(dataItem == null ? null : ZuliItem.fromJson(dataItem));
    }
  }

  @override
  String toString() {
    return '{"code": $code, "mpa": $mpa, "msg": ${msg != null?'${json.encode(msg)}':'null'}, "data": $data}';
  }

  String toJson() => this.toString();
}

class ZuliItem {

  String item;

  ZuliItem.fromParams({this.item});

  ZuliItem.fromJson(jsonRes) {
    item = jsonRes['item'];
  }

  @override
  String toString() {
    return '{"item": ${item != null?'${json.encode(item)}':'null'}}';
  }

  String toJson() => this.toString();
}


class ZuliSJson {

  int code;
  double mpa;
  String data;
  String msg;

  ZuliSJson.fromParams({this.code, this.mpa, this.data, this.msg});

  factory ZuliSJson(Object jsonStr) => jsonStr is String ? ZuliSJson.fromJson(json.decode(jsonStr)) : ZuliSJson.fromJson(jsonStr);

  static ZuliSJson parse(jsonStr) => ['null', '', null].contains(jsonStr) ? null : ZuliSJson(jsonStr);

  ZuliSJson.fromJson(jsonRes) {
    code = jsonRes['code'];
    mpa = jsonRes['mpa'];
    data = jsonRes['data'];
    msg = jsonRes['msg'];
  }

  @override
  String toString() {
    return '{"code": $code, "mpa": $mpa, "data": ${data != null?'${json.encode(data)}':'null'}, "msg": ${msg != null?'${json.encode(msg)}':'null'}}';
  }

  String toJson() => this.toString();
}



class ShuiBengJson {

  int code;
  double mpa;
  String data;
  String msg;

  ShuiBengJson.fromParams({this.code, this.mpa, this.data, this.msg});

  factory ShuiBengJson(Object jsonStr) => jsonStr is String ? ShuiBengJson.fromJson(json.decode(jsonStr)) : ShuiBengJson.fromJson(jsonStr);

  static ShuiBengJson parse(jsonStr) => ['null', '', null].contains(jsonStr) ? null : ShuiBengJson(jsonStr);

  ShuiBengJson.fromJson(jsonRes) {
    code = jsonRes['code'];
    mpa = jsonRes['mpa'];
    data = jsonRes['data'];
    msg = jsonRes['msg'];
  }

  @override
  String toString() {
    return '{"code": $code, "mpa": $mpa, "data": ${data != null?'${json.encode(data)}':'null'}, "msg": ${msg != null?'${json.encode(msg)}':'null'}}';
  }

  String toJson() => this.toString();
}

class HrqJson {

  int code;
  double mpa;
  String data;
  String msg;

  HrqJson.fromParams({this.code, this.mpa, this.data, this.msg});

  factory HrqJson(Object jsonStr) => jsonStr is String ? HrqJson.fromJson(json.decode(jsonStr)) : HrqJson.fromJson(jsonStr);

  static HrqJson parse(jsonStr) => ['null', '', null].contains(jsonStr) ? null : HrqJson(jsonStr);

  HrqJson.fromJson(jsonRes) {
    code = jsonRes['code'];
    mpa = jsonRes['mpa'];
    data = jsonRes['data'];
    msg = jsonRes['msg'];
  }

  @override
  String toString() {
    return '{"code": $code, "mpa": $mpa, "data": ${data != null?'${json.encode(data)}':'null'}, "msg": ${msg != null?'${json.encode(msg)}':'null'}}';
  }

  String toJson() => this.toString();
}



class FormLcJson {

  int code;
  double mpa;
  String msg;
  List<InfoData> data;
  Pages cond;

  FormLcJson.fromParams({this.code, this.mpa, this.msg, this.data, this.cond});

  factory FormLcJson(Object jsonStr) => jsonStr is String ? FormLcJson.fromJson(json.decode(jsonStr)) : FormLcJson.fromJson(jsonStr);

  static FormLcJson parse(jsonStr) => ['null', '', null].contains(jsonStr) ? null : FormLcJson(jsonStr);

  FormLcJson.fromJson(jsonRes) {
    code = jsonRes['code'];
    mpa = jsonRes['mpa'];
    msg = jsonRes['msg'];
    data = jsonRes['data'] == null ? null : [];

    for (var dataItem in data == null ? [] : jsonRes['data']){
      data.add(dataItem == null ? null : InfoData.fromJson(dataItem));
    }

    cond = jsonRes['cond'] == null ? null : Pages.fromJson(jsonRes['cond']);
  }

  @override
  String toString() {
    return '{"code": $code, "mpa": $mpa, "msg": ${msg != null?'${json.encode(msg)}':'null'}, "data": $data, "cond": $cond}';
  }

  String toJson() => this.toString();
}

class Pages {

  int page;
  int perPage;
  int total;

  Pages.fromParams({this.page, this.perPage, this.total});

  Pages.fromJson(jsonRes) {
    page = jsonRes['page'];
    perPage = jsonRes['perPage'];
    total = jsonRes['total'];
  }

  @override
  String toString() {
    return '{"page": $page, "perPage": $perPage, "total": $total}';
  }

  String toJson() => this.toString();
}

class InfoData {

  String introduce;
  String link;
  String mores;
  String title;

  InfoData.fromParams({this.introduce, this.link, this.mores, this.title});

  InfoData.fromJson(jsonRes) {
    introduce = jsonRes['introduce'];
    link = jsonRes['link'];
    mores = jsonRes['mores'];
    title = jsonRes['title'];
  }

  @override
  String toString() {
    return '{"introduce": ${introduce != null?'${json.encode(introduce)}':'null'}, "link": ${link != null?'${json.encode(link)}':'null'}, "mores": ${mores != null?'${json.encode(mores)}':'null'}, "title": ${title != null?'${json.encode(title)}':'null'}}';
  }

  String toJson() => this.toString();
}




class LoginJson {

  int code;
  double mpa;
  String msg;

  LoginJson.fromParams({this.code, this.mpa, this.msg});

  factory LoginJson(Object jsonStr) => jsonStr is String ? LoginJson.fromJson(json.decode(jsonStr)) : LoginJson.fromJson(jsonStr);

  static LoginJson parse(jsonStr) => ['null', '', null].contains(jsonStr) ? null : LoginJson(jsonStr);

  LoginJson.fromJson(jsonRes) {
    code = jsonRes['code'];
    mpa = jsonRes['mpa'];
    msg = jsonRes['msg'];
  }

  @override
  String toString() {
    return '{"code": $code, "mpa": $mpa, "msg": ${msg != null?'${json.encode(msg)}':'null'}}';
  }

  String toJson() => this.toString();
}